use ash::vk::{self, ImageSubresourceRange, CommandPoolCreateFlags};

use crate::vulkan::{VkContext, vk_struct::{QueueType, VkQueue}};

impl VkContext {
    fn get_command_pool_ci() -> vk::CommandPoolCreateInfo {
        vk::CommandPoolCreateInfo {
            s_type                  : vk::StructureType::COMMAND_POOL_CREATE_INFO,
            p_next                  : std::ptr::null(),
            // flags                   : CommandPoolCreateFlags::RESET_COMMAND_BUFFER,
            // queue_family_index

            ..Default::default()
        }
    }
    
    pub fn init_command_pool(vk_device: &ash::Device, vk_queue_map: &Vec<Vec<VkQueue>>) -> vk::CommandPool {
        let mut command_pool_ci = Self::get_command_pool_ci();
        command_pool_ci.flags               = CommandPoolCreateFlags::RESET_COMMAND_BUFFER;
        command_pool_ci.queue_family_index  = vk_queue_map[QueueType::GTC as usize][0].family_index;

        let command_pool = unsafe {
            vk_device
                .create_command_pool(&command_pool_ci, None)
                .expect("failed to create command pool!")
        };

        command_pool
    }
}